// pages/singleSupers/singleSupers.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    superDetail:{}
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    //console.log(options.id)
    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          winHeight: res.windowHeight,
          shop_id: options.id,
          imageUrl: app.globalData.imageUrl
        })
      },
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },
  makePhone: function (e) {
    //console.log(e.target.id)
    var that = this;
    wx.makePhoneCall({
      phoneNumber: e.target.id,
    })
  },
  goToLocaltion: function (e) {
    var that = this;
    var latitude = that.data.list[0].latitude;
    var longitude = that.data.list[0].longitude;
    wx.openLocation({
      latitude:  latitude,//30.68104,
      longitude: longitude//104.00387,
    })

  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    getBackShoppingInfo(this)//获取商家信息    
  },
  gotoLocaltion(){
    var that=this;
    wx.openLocation({
      latitude: parseFloat(that.data.superDetail.gps_w) ,
      longitude: parseFloat(that.data.superDetail.gps_j),
    })
  } 
})

function getBackShoppingInfo(that) {
    wx.request({
      url: app.globalData.allUrl + "/shop/shoplist",
      data: {
        shop_id: that.data.shop_id
      },
      method: 'POST', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
      // header: {}, // 设置请求的 header
      success: function (res) {
        console.log(res.data)
        that.setData({
          superDetail: res.data.data
        })
      }
    })

}